/*
 * This file is part of Dorado 7.x (http://dorado7.bsdn.org).
 * 
 * Copyright (c) 2002-2012 BSTEK Corp. All rights reserved.
 * 
 * This file is dual-licensed under the AGPLv3 (http://www.gnu.org/licenses/agpl-3.0.html) 
 * and BSDN commercial (http://www.bsdn.org/licenses) licenses.
 * 
 * If you are unsure which license is appropriate for your use, please contact the sales department
 * at http://www.bstek.com/contact.
 */

package com.bstek.dorado.view.output;

import com.bstek.dorado.data.type.AggregationDataType;
import com.bstek.dorado.data.type.DataType;
import com.bstek.dorado.data.type.EntityDataType;

/**
 * @author Benny Bao (mailto:benny.bao@bstek.com)
 * @since 2014-5-15
 */
public class AbstractDataTypeOutputter extends ObjectOutputterDispatcher {

	protected DataType getOutputDataType(DataType dataType,
			OutputContext context) {
		if (dataType instanceof AggregationDataType) {
			DataType elementDataType = ((AggregationDataType) dataType)
					.getElementDataType();
			if (elementDataType instanceof EntityDataType) {
				dataType = elementDataType;
			} else {
				dataType = null;
			}
		} else if (!(dataType instanceof EntityDataType)) {
			dataType = null;
		}
		return dataType;
	}

}